# Makefile v0.3 2014-02-27
# Flavio Bertini fl.bertini@gmail.com


# Library and Header
# WARNING: Remember to export LD_LIBRARY_PATH=/usr/lib/Leap/  ../libx86/
INCLUDE      := ../include
LEAP_PATHLIB := ../libx86/
GL_LIB       := -lm -lGL -lGLU -lglut
LEAP_LIB     := libLeap.so
LIB          := $(LEAP_PATHLIB)$(LEAP_LIB) $(GL_LIB)
MATH_UTIL    := Math.o
CRAFTMESH    := Craftmesh_model.o Craftmesh_gengine.o Craftmesh_viewer.o Craftmesh_controller.o Craftmesh.o
OBJECTS      := $(LEAP_UTIL) $(MATH_UTIL) $(CRAFTMESH)

#Flags
BIN      := Craftmesh
STANDARD := -std=c++98
WARNINGS := -ansi -pedantic -Wall -Werror -Wunused-function -Wunused-value -Wunused-result \
            -Wunused-variable -Wunused-but-set-variable
CPPFLAGS := -g -pg -O0
FLAGS    := $(STANDARD) $(WARNINGS) $(CPPFLAGS)


# Compiling section
all: Craftmesh

Craftmesh: $(OBJECTS)
	@echo "Linking Craftmesh Project ... ok"
	@$(CXX) $(FLAGS) -I$(INCLUDE) $(OBJECTS) -o $(BIN) $(LIB)
	@echo "======================================"

Math.o: Math.cpp
	clear
	@echo "======================================"
	@echo "        CRAFTMESH PROJECT"
	@echo ""
	@echo "Compiling Math Utility ... ok"
	@$(CXX) $(FLAGS) -I$(INCLUDE) -o "$@" -c "$<"

Craftmesh_model.o: Craftmesh_model.cpp
	@echo "Compiling Craftmesh Model ... ok"
	@$(CXX) $(FLAGS) -I$(INCLUDE) -o "$@" -c "$<"

Craftmesh_gengine.o: Craftmesh_gengine.cpp
	@echo "Compiling Craftmesh Gengine ... ok"
	@$(CXX) $(FLAGS) -I$(INCLUDE) -o "$@" -c "$<"

Craftmesh_viewer.o: Craftmesh_viewer.cpp
	@echo "Compiling Craftmesh Viewer ... ok"
	@$(CXX) $(FLAGS) -I$(INCLUDE) -o "$@" -c "$<"

Craftmesh_controller.o: Craftmesh_controller.cpp $(LEAP_UTIL)
	@echo "Compiling Craftmesh Controller ... ok"
	@$(CXX) $(FLAGS) -I$(INCLUDE) -o "$@" -c "$<"

Craftmesh.o: Craftmesh.cpp
	@echo "Compiling Craftmesh Project ... ok"
	@$(CXX) $(FLAGS) -I$(INCLUDE) -o "$@" -c "$<"


# Clear section
clean:
	clear
	@rm -rf $(BIN) $(OBJECTS) *.bin leaplog.txt *.o *~ $(INCLUDE)/*~
	@echo "======================================"
	@echo "              Removed all!"
	@echo "======================================"
